package br.com.tiespec.web.Converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import br.com.tiespec.ejb.Dao.AtorDAO;
import br.com.tiespec.model.Modelo.Ator;

public class AtorConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext ctx, UIComponent component, String value) {
		System.out.println(value);
		if (value == null)
			return null;
		AtorDAO aDao = new AtorDAO();
		return aDao.selecionar(Long.parseLong(value));
	}

	@Override
	public String getAsString(FacesContext ctx, UIComponent component, Object value) {
		Ator a = (Ator) value;
		return "" + a.getId();
	}

}
